//
//  WBBaseTableViewController.swift
//  微博
//
//  Created by lipengfei on 15/9/3.
//  Copyright © 2015年 lipengfei. All rights reserved.
//

import UIKit

class WBBaseTableViewController: UITableViewController {

    ///在设置登录属性，如果用户没有登录，跳转到登录界面
    var login:Bool = WBUserAccountViewModel.sharedUserAccount.userLogin
    //创建 visitorLoginView
    var visitorLoginView :WBbaseView?
    override func viewDidLoad() {
        super.viewDidLoad()
        login ? super.loadView() : setupView()
    }
    
    func setupView(){
        visitorLoginView = WBbaseView()
        view = visitorLoginView
        view.backgroundColor = UIColor(red: 237.0/255, green: 237.0/255, blue: 237.0/255, alpha: 1)
        navigationItem.setLeftBarButtonItem(UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "clickRegister"), animated: true)
        navigationItem.setRightBarButtonItem(UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "clickLogin"), animated: true)
        visitorLoginView?.registerView.addTarget(self, action: "clickRegister", forControlEvents: UIControlEvents.TouchUpInside)
        visitorLoginView?.loginView.addTarget(self, action: "clickLogin", forControlEvents: UIControlEvents.TouchUpInside)
    }

    func clickRegister(){
    print("注册")
    }
    func clickLogin(){
    
        let nav = UINavigationController(rootViewController: WBOAuthViewController())
        presentViewController(nav, animated: true, completion: nil)
    }
   }
